#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <errno.h>
#define GEC6818_GET_DHTDATA  _IOR('K', 0, unsigned int) //注册宏

int main(void)
{
	int ret;
	unsigned char data[2];
	int ultrasonic_fd = open("/dev/dht11_dev", O_RDWR);
	if(ultrasonic_fd < 0)
	{
		perror("open dht11_dev driver");
		return -1;
	}				
	while(1)
	{
		printf("检测中\n");
		ret = ioctl(ultrasonic_fd, GEC6818_GET_DHTDATA, &data[0]);
		if(ret != 0)
		{
			perror("GEC6818_GET_DHTDATA error");
		}
		else
		{
			printf("湿度= %hhd  温度=%hhd\n", data[1], data[0]);
		}
		usleep(1000*2000);
	}
	close(ultrasonic_fd);
	
	return 0;
}